package StudyCode.summary.Basic.stringbuilder;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class StringBuilderMethod1 {
	public static void main(String[] args) {
		StringBuilder stringBuilder = new StringBuilder("Hello World");

		System.out.printf("StringBuilder = %s\n", stringBuilder.toString());
		System.out.printf("索引为0字符是: %s\n索引为4字符是: %s\n\n", stringBuilder.charAt(0), stringBuilder.charAt(4));

		char[] charArray = new char[stringBuilder.length()];
		stringBuilder.getChars(0, stringBuilder.length(), charArray, 0);
		System.out.print("所有字符: ");

		for (char character : charArray) {
			System.out.print(character);
		}

		stringBuilder.setCharAt(0, 'h');
		stringBuilder.setCharAt(6, 'T');
		System.out.printf("\n\n更改字符后StringBuilder = %s", stringBuilder.toString());
		stringBuilder.reverse();
		System.out.printf("\n\n反向后 StringBuilder = %s\n", stringBuilder.toString());
	}
}
